/**
* @todo：页面初始化
* @date：15:58 2008-2-26
* @author：hyh
*/
function pageInit(){
	var type = JSRequest("type");
	if(type= "usernoralerole"){
		loadAcluserNoRelaAclroleList();
	}
}

/**
* @todo：查询角色未关联的用户
* @date：15:58 2008-2-26
* @author：hyh
*/
function loadAcluserNoRelaAclroleList(page,pageSize){
	if(typeof(page) == "undefined"){
		page = 1;
	}
	if(typeof(pageSize) == "undefined"){
		pageSize = 15;
	}
	var oJSsearchBean = new JSsearchBean();
	oJSsearchBean.roleid = JSRequest("roleid");
	oJSsearchBean.realname = DWRUtil.getValue("realname");
	oJSsearchBean.account = DWRUtil.getValue("account");
	DWRUtil.useLoadingMessage("正在读取数据...");
	ConfigAction.listAcluserNoRelaAclroleByRoleId(oJSsearchBean,page,pageSize,function(pageObject){
		  var data = pageObject.resultList;
		  var rowNum = 1;
		  var i = 1;
		  DWRUtil.removeAllRows("user_table");
		  var cellFuncs = [
		  function(data) {
			  return "<input type=\"checkbox\" name=\"userchkbox\" value=\""+data.id+"\" class=\"checkbox\">";
		  },
		  function(data) {//用户帐号
			  if(data.account == "null" || data.account == null){
				  return "";
			  }else{
				  return data.account;
			  }
		  },
		  function(data) {//用户名称
			  if(data.realname == "null" || data.realname == null){
				  return "";
			  }else{
				  return data.realname;
			  }	  
		  },
		  function(data) {//用户状态
			  if(data.userstatus == "null" || data.userstatus == null){
				  return "";
			  }else if(data.userstatus == "1"){
			  	  return "激活";
			  }else if(data.userstatus == "2"){
			  	  return "未激活";
			  }else{
			  	  return "已删除";
			  }
		  },
		  function(data) {//是否在线
			  if(data.isonline == "null" || data.isonline == null){
				  return "";
			  }else if(data.isonline == "1"){
			  	  return "在线";
			  }else{
			  	  return "未在线";
			  }
		  },
		  function(data) {//创建日期
			  if(data.createdate == "null" || data.createdate == null){
				  return "";
			  }else{
				  return formatDate(data.createdate);
			  }	  
		  },
		  function(data) {//小灵通
			  if(data.pas == "null" || data.pas == null){
				  return "";
			  }else{
				  return data.pas;
			  }	  
		  },
		   function(data) {//手机
			  if(data.mobile == "null" || data.mobile == null){
				  return "";
			  }else{
				  return data.mobile;
			  }	  
		  },
		   function(data) {//联系电话
			  if(data.telphone == "null" || data.telphone == null){
				  return "";
			  }else{
				  return data.telphone;
			  }	  
		  },
		  function(data) {
			return "<a href=\"#\" onclick=\"openAcluserop('"+data.id+"');return false;\"><img src=\"../themes/default/images/edit2.gif\" border=\"0\" width=\"15\" height=\"15\" valign=\"bottom\" alt=\"编辑\"></a>";
		  }
		  ];
		  DWRUtil.addRows("user_table",data,cellFuncs,{
		  rowCreator:function(options) {
		    var row = document.createElement("tr");
			if(rowNum == 1){
				row.className="list_black";
				row.onmouseover= function(){cListTr(this,'list_content_over');}
				row.onmouseout = function(){cListTr(this,'list_black');}
				rowNum = 0;
			}else{
				row.className="list_content";
				row.onmouseover= function(){cListTr(this,'list_content_over');}
				row.onmouseout = function(){cListTr(this,'list_content');}
				rowNum = 1;
			}	
		    return row;
		  },
		  cellCreator:function(options) {
		    var td = document.createElement("td");
		    var cellNum = options.cellNum;
		    td.align = "center";
			//td.height = "28";
		    return td;
		  },
		  escapeHtml:false
		  });
		  /**分页-----------------------------------------------------*/
		  var func_ = "loadAcluserNoRelaAclroleList(page,15)";
		  var htmlStr = showPage(pageObject,func_);//对象和方法
		  DWRUtil.setValue("user_page_div",htmlStr,{escapeHtml:false});
		  addTableRolloverEffect('table_userforother_query','tableRollOverEffect1','tableRowClickEffect1');
		  initSortTable('table_userforother_query',Array('','S','S','S','S','S',''));
	});
}

/**
* @todo：添加用户for other
* @date：9:11 2008-2-27
* @author：hyh
*/
function addUserForOther(){
	DWRUtil.useLoadingMessage("正在读取数据...");
	var type = JSRequest("type");
	var userIds = getCheckValuesByName("userchkbox");
	if(userIds == ""){
		alert("请至少选择一条记录！");
		return false;
	}
	if(confirm("你确定添加用户吗？")){
		if(type= "usernoralerole"){
			var roleid = JSRequest("roleid");
			if(roleid == ""){
				alert("角色ID不能为空！");
				return false;
			}
			ConfigAction.insertAclrelaroleuser(roleid,userIds,function(data){
				alert(data);
				pageInit();
			});
		}
	}
}

//@see next js function is for userquery common function 15:59 2008-2-26

//open add or edit or detail page
function openAcluserop(id){
	var url = "acluserop.html"
	if(id){
		url += "?id=" + id + "&pagetype=userquery";
	}
	openWin_h(url,"800","500");
	return false;
}

/**set search bean 15:59 2008-2-26*/
function JSsearchBean(){
	this.roleid = "";
	this.realname = "";
	this.account = "";
}